package com.beta.elephant.exception;


import com.beta.elephant.vo.BaseResultCode;

import java.io.Serializable;

public class BusinessException extends RuntimeException implements Serializable {

    // 默认错误码是500，防止系统出现未知的异常
    private int code = 500;

    // 错误信息
    private String msg = "系统出了故障，请稍后再试！";

    private BaseResultCode resultCode;

    public BusinessException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BusinessException(BaseResultCode resultCode) {
        this.resultCode = resultCode;
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public BaseResultCode getResultCode() {
        return resultCode;
    }
}
